home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / bibinputs / BTXBST / DOC
Encoding:
Text File  |  1991-02-10  |  55.6 KB  |  2,290 lines

  1. # if 0
  2. % BibTeX `plain' family
  3. % modified to ouput fields in French; shapiro@corto.inria.fr 30-oct-87
  4. % Further modified for 'alpha3' and 'long' styles 3-nov-87
  5. # endif 0
  6.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  7.     % Copyright (C) 1985, all rights reserved
  8.     % Copying of this file is authorized only if either
  9.     % (1) you make absolutely no changes to your copy, including name, or
  10.     % (2) if you do make changes, you name it something other than
  11.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  12.     % This restriction helps ensure that all standard styles are identical
  13. # if 0
  14. % This is file btxbxt.doc; it helps document bibliography styles,
  15. % and is also a template file that you can use to make
  16. % several different style files, if you have access to a C preprocessor.
  17. % For example, the standard styles were made by something like
  18. %    cpp -P -DPLAIN btxbst.doc plain.bst
  19. %    cpp -P -DUNSRT btxbst.doc unsrt.bst
  20. %    cpp -P -DALPHA btxbst.doc alpha.bst
  21. %    cpp -P -DABBRV btxbst.doc abbrv.bst
  22. % A French version of (say) abbrv is created by
  23. %    cpp -P -DABBRV -DFRENCH btxbst.doc abbrv.txt
  24. % There are also new styles created by defining ALPHA3, KEY, SKEY or LONG.
  25. %       ALPHA3 label is first 3 letters of 1st author's name + year
  26. %       LONG   label is 1st author's full name + year
  27. %       KEY    label is the bibtex key, the bibliogrpahy is unsorted
  28. %       SKEY   label is the bibtex key, sorted by author's name
  29. % The last two styles are intended for printing the database itself.
  30. %
  31. % If you don't have access,
  32. % you can edit this file by hand to imitate the preprocessor,
  33. % with the following explanation of the C preprocessor constructs used here.
  34. %
  35. % The output of the preprocessor is the same as the input, except that certain
  36. % lines will be excluded (and some blank lines will be added).  The sequence
  37. %    #if VAR
  38. %        lines to be included when VAR is not zero
  39. %    #else
  40. %        lines to be included when VAR is zero
  41. %    #endif
  42. % (with the #-signs appearing in column 1) means that one set or the other of
  43. % the lines are to be included depending on the value of VAR.
  44. % The #else part is optional.  Comments can be added after #else and #endif.
  45. % The '# if 0' ... '#endif' sequence is used to eliminate unnecessary
  46. % comments from the output.
  47. % Variables can be set by
  48. %    #define VAR value
  49. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  50. % to see if it has none.
  51. % Another #if form used in this file is #if !VAR, which includes the lines
  52. % after the #if only if VAR is zero.
  53. %
  54. % Convention: Use all uppercase identifiers for these preprocessor variables
  55. % so you can spot them easily
  56. %
  57. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  58. % or ABBRV (though PLAIN will be used by default if none is given),
  59. % and the following lines will set various boolean variables to control the
  60. % various lines that are chosen from the rest of the file.
  61. % Each boolean variable should be set true (1) or false (0) in each style.
  62. % Here are the current variables, and their meanings:
  63. %    LAB_ALPH:    an alphabetic label is used (if false then a numeric
  64. %                label is used)
  65. %    SORTED:        the entries should be sorted by label (if nonnumeric)
  66. %                and other info, like authors (if false, then
  67. %                entries remain in order of occurrence)
  68. %    NAME_FULL:    the authors, editors, etc., get the full names as
  69. %                given in the bibliograph (if false, the first
  70. %                names become initials)
  71. %    ATIT_LOWER:    titles of non-"books" (e.g., articles) should be
  72. %                converted to lower-case, except the first letter
  73. %                (if false then they appear as in the database)
  74. %    MONTH_FULL:    months are spelled out in full (if false, then
  75. %                they're abbreviated)
  76. %    JOUR_FULL:    macro journal names are spelled out in full
  77. %                (if false then they are abbreviated, currently
  78. %                as they appear in ACM publications)
  79. %       LBKEYS:         use the database key as the citation label
  80. % Furthermore the variable ALPHA_LONG may have one of the following
  81. % values, when LAB_ALPH is 1, giving the following citation alphabetic
  82. % label format:
  83. % 0 [Lam85] for single author (or editor or key): first 3 letters of last name
  84. %   [SW79]  (first letters of last names) for multiple authors
  85. % 1 [Lam85] for single author (or editor or key)
  86. %   [Str79]  (first 3 letters of 1st author's last name) for multiple authors
  87. % 2 [Lamport 85] for single author (or editor or key): full last name
  88. %   [Strunk 79]  (full last name of 1st author) for multiple authors
  89. # endif 0
  90.  
  91. #ifndef UNSRT
  92. #   ifndef ALPHA
  93. #    ifndef ABBRV
  94. #           ifndef ALPHA3
  95. #               ifndef LONG
  96. #                   ifndef KEY
  97. #                       ifndef SKEY
  98. #                              define PLAIN 1
  99. #                       endif
  100. #                   endif
  101. #               endif
  102. #           endif
  103. #    endif
  104. #   endif
  105. #endif
  106. #ifdef PLAIN
  107. % plain style (sorted numbers)
  108. #   define LAB_ALPH 0
  109. #   define SORTED 1
  110. #   define NAME_FULL 1
  111. #   define ATIT_LOWER 1
  112. #   define MONTH_FULL 1
  113. #   define JOUR_FULL 1
  114. #   define LBKEYS 0
  115. #endif
  116. #ifdef UNSRT
  117. % unsrt style (unsorted numbers)
  118. #   define LAB_ALPH 0
  119. #   define SORTED 0
  120. #   define NAME_FULL 1
  121. #   define ATIT_LOWER 1
  122. #   define MONTH_FULL 1
  123. #   define JOUR_FULL 1
  124. #   define LBKEYS 0
  125. #endif
  126. #ifdef ALPHA
  127. % alpha style (sorted short alphabetics)
  128. #   define LAB_ALPH 1
  129. #   define ALPHA_LONG 0
  130. #   define SORTED 1
  131. #   define NAME_FULL 1
  132. #   define ATIT_LOWER 1
  133. #   define MONTH_FULL 1
  134. #   define JOUR_FULL 1
  135. #   define LBKEYS 0
  136. #endif
  137. #ifdef ALPHA3
  138. % alpha style (sorted short alphabetics, 1st author only)
  139. #   define LAB_ALPH 1
  140. #   define ALPHA_LONG 1
  141. #   define SORTED 1
  142. #   define NAME_FULL 1
  143. #   define ATIT_LOWER 1
  144. #   define MONTH_FULL 1
  145. #   define JOUR_FULL 1
  146. #   define LBKEYS 0
  147. #endif
  148. #ifdef LONG
  149. % alpha style (sorted long alphabetics, 1st author only)
  150. #   define LAB_ALPH 1
  151. #   define ALPHA_LONG 2
  152. #   define SORTED 1
  153. #   define NAME_FULL 1
  154. #   define ATIT_LOWER 1
  155. #   define MONTH_FULL 1
  156. #   define JOUR_FULL 1
  157. #   define LBKEYS 0
  158. #endif
  159. #ifdef ABBRV
  160. % abbrv style (sorted numbers, with abbreviations)
  161. #   define LAB_ALPH 0
  162. #   define SORTED 1
  163. #   define JOUR_FULL 0
  164. #   define MONTH_FULL 0
  165. #   define ATIT_LOWER 1
  166. #   define NAME_FULL 0
  167. #   define LBKEYS 0
  168. #endif
  169. #ifdef KEY
  170. % keys style (unsorted keys)
  171. #   define LAB_ALPH 1
  172. #   define SORTED 0
  173. #   define NAME_FULL 0
  174. #   define ATIT_LOWER 1
  175. #   define MONTH_FULL 0
  176. #   define JOUR_FULL 1
  177. #   define LBKEYS 1
  178. #endif
  179. #ifdef SKEY
  180. % skeys style (sorted keys)
  181. #   define LAB_ALPH 1
  182. #   define SORTED 1
  183. #   define NAME_FULL 1
  184. #   define ATIT_LOWER 1
  185. #   define MONTH_FULL 0
  186. #   define JOUR_FULL 1
  187. #   define LBKEYS 1
  188. #endif
  189. #ifdef FRENCH
  190. % French version
  191. #endif FRENCH
  192. %
  193. # if 0
  194. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  195. %    in "A Handbook for Scholars".  Book-like titles are italicized and
  196. %    non-book titles are converted to sentence capitilization
  197. %    (and not enclosed in quotes).
  198. %    This file outputs a \newblock between major blocks of an entry
  199. %    (the name \newblock is analogous to the names \newline and \newpage)
  200. %    so that the user can obtain an "open" format, which has a line break
  201. %    before each block and lines after the first are indented within blocks,
  202. %    by giving an optional \documentstyle argument; currently there is a
  203. %    required `optional' \documentstyle argument, one of
  204. %        opbiba, opbibr, clbiba, or clbibr,
  205. %    giving an open or closed format for an article or report.
  206. %    For the next version of LaTeX there will be just one, truly optional
  207. %    style, for the open format
  208. %    (among other things, it will have improved page breaking).
  209. %    The default will be the "closed" format---blocks runs together.
  210. %
  211. %   Citation alphabetic label format:
  212. %        [Knu73] for single author (or editor or key)
  213. %        [AHU83] (first letters of last names) for multiple authors
  214. %
  215. %   Citation label numberic format:
  216. %        [number]
  217. %
  218. %   Reference list ordering for sorted, alphabetic lables:
  219. %        alphabetical by citation label, then by author(s) or whatever
  220. %        passes for author in the absence of one, and then by title.
  221. %
  222. %   Reference list ordering for sorted, numeric lables:
  223. %        alphabetical by author(s) or whatever passes
  224. %        passes for author in the absence of one, and then by title.
  225. %
  226. %   Reference list ordering for unsorted:
  227. %        by the order cited in the text
  228. %
  229. %   History
  230. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  231. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  232. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik
  233. %    2/17/85    (HWT)    template file and other standard styles made
  234. %    3/28/85        First release, version 0.98b for BibTeX 0.98f
  235. %    5/ 9/85        version 0.98c for BibTeX 0.98i
  236. %             : fixed Theoretical Computer Science macro name
  237. %             : fixed the format.vol.num.pages function
  238. %
  239. % The ENTRY declaration
  240. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  241. %   but no fullauthor or editors fields because BibTeX does name handling.
  242. %   The annote field is commented out here because this family doesn't
  243. %   include an annotated bibliography style
  244. # endif 0
  245.  
  246. ENTRY
  247. % Fields:
  248.   { address
  249. %        Publisher's address
  250. %    annote
  251. %        Long annotation used for annotated bibliographies (begins sentence)
  252.     author
  253. %        Name(s) of author(s), in BibTeX name format
  254.     booktitle
  255. %        Book title when the thing being referenced isn't the whole book.
  256. %        For book entries, the title field should be used instead.
  257.     chapter
  258. %        Chapter number
  259.     edition
  260. %        Edition of a book (e.g., "second")
  261.     editor
  262. %        Name(s) of editor(s), in BibTeX name format.
  263. %        If there is also an author field, then the editor field should be
  264. %        for the book or collection that the work appears in
  265.     howpublished
  266. %         How something strange has been published (begins sentence)
  267.     institution
  268. %        Sponsoring institution
  269.     journal
  270. %        Journal name (macros are provided for many)
  271.     key
  272. %        Alphabetizing and labeling key (needed when no author or editor)
  273.     month
  274. %        Month (macros are provided)
  275.     note
  276. %        To help the reader find a reference (begins sentence)
  277.     number
  278. %        Number of a journal or technical report
  279.     organization
  280. %        Organization (sponsoring a conference)
  281.     pages
  282. %        Page number or numbers (use `--' to separate a range)
  283.     publisher
  284. %        Publisher name
  285.     school
  286. %        School name (for theses)
  287.     series
  288. %        The name of a series or set of books.
  289. %        An individual book will will also have it's own title
  290.     title
  291. %        The title of the thing being referenced
  292.     type
  293. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  294. %        the default "Technical Report"
  295.     volume
  296. %        Volume of a journal or multivolume work
  297.     year
  298. %        Year---should contain only numerals
  299.   }
  300. # if 0
  301. % There are no integer entry variables
  302. # endif 0
  303.   {}
  304. # if 0
  305. % These string entry variables are used to form the citation label.
  306. % In a storage pinch, sort.label can be easily computed on the fly.
  307. # endif 0
  308.  
  309. #if LAB_ALPH
  310. #if SORTED
  311.   { label extra.label sort.label }
  312. #else !SORTED
  313. # if 0
  314. % It still doesn't seem like a good idea to use an order-of-citation
  315. % reference list when using alphabetic labels, but when this happens we
  316. % do things a little differently
  317. # endif 0
  318.   {label}
  319. #endif SORTED
  320. #else !LAB_ALPH
  321.   {label}
  322. #endif LAB_ALPH
  323.  
  324. # if 0
  325. % Each entry function starts by calling output.bibitem, to write the
  326. % \bibitem and its arguments to the .BBL file.  Then the various fields
  327. % are formatted and printed by output or output.check.  Those functions
  328. % handle the writing of separators (commas, periods, \newblock's),
  329. % taking care not to do so when they are passed a null string.
  330. % Finally, fin.entry is called to add the final period and finish the
  331. % entry.
  332. %
  333. % A bibliographic reference is formatted into a number of `blocks':
  334. % in the open format, a block begins on a new line and subsequent
  335. % lines of the block are indented.  A block may contain more than
  336. % one sentence (well, not a grammatical sentence, but something to
  337. % be ended with a sentence ending period).  The entry functions should
  338. % call new.block whenever a block other than the first is about to be
  339. % started.  They should call new.sentence whenever a new sentence is
  340. % to be started.  The output functions will ensure that if two
  341. % new.sentence's occur without any non-null string being output between
  342. % them then there won't be two periods output.  Similarly for two
  343. % successive new.block's.
  344. %
  345. % The output routines don't write their argument immediately.
  346. % Instead, by convention, that argument is saved on the stack to be
  347. % output next time (when we'll know what separator needs to come
  348. % after it).  Meanwhile, the output routine has to pop the pending
  349. % output off the stack, append any needed separator, and write it.
  350. %
  351. % To tell which separator is needed, we maintain an output.state.
  352. % It will be one of these values:
  353. %    before.all        just after the \bibitem
  354. %    mid.sentence        in the middle of a sentence: comma needed
  355. %                    if more sentence is output
  356. %    after.sentence        just after a sentence: period needed
  357. %    after.block        just after a block (and sentence):
  358. %                    period and \newblock needed.
  359. % Note: These styles don't use after.sentence
  360. %
  361. % VAR: output.state : INTEGER        -- state variable for output
  362. %
  363. % The output.nonnull function saves its argument (assumed to be nonnull)
  364. % on the stack, and writes the old saved value followed by any needed
  365. % separator.  The ordering of the tests is decreasing frequency of
  366. % occurrence.
  367. %
  368. % output.nonnull(s) ==
  369. %  BEGIN
  370. %    s := argument on stack
  371. %    if output.state = mid.sentence then
  372. %        write$(pop() * ", ")
  373. %          -- "pop" isn't a function: just use stack top
  374. %    else
  375. %        if output.state = after.block then
  376. %        write$(add.period$(pop()))
  377. %        newline$
  378. %        write$("\newblock ")
  379. %        else
  380. %        if output.state = before.all then
  381. %            write$(pop())
  382. %        else        -- output.state should be after.sentence
  383. %            write$(add.period$(pop()) * " ")
  384. %        fi
  385. %        fi
  386. %    fi
  387. %    push s on stack
  388. %    output.state := mid.sentence
  389. %  END
  390. %
  391. % The output function calls output.nonnull if its argument is non-null
  392. %
  393. % output(s) ==
  394. %  BEGIN
  395. %    if s <> "" then output.nonnull(s)
  396. %    fi
  397. %  END
  398. %
  399. % The output.check function calls output.nonnull if s is non-null
  400. % and warns the user that the t field shouldn't be empty (this is
  401. % because it won't be a good reference without the field;  the entry
  402. % functions try to make the formatting look reasonable even when such
  403. % fields are empty).
  404. %
  405. % output.check(t,s) ==
  406. %  BEGIN
  407. %    if s = "" then
  408. %        top$("Warning: the " * t * " shouldn't be empty in " * cite$)
  409. %    else output.nonnull(s)
  410. %    fi
  411. %  END
  412. %
  413. % The output.bibitem function writes the \bibitem for the current entry
  414. % (the label should already have been set up), and sets up the separator
  415. % state for the output functions.  And, it leaves a string on the stack
  416. % as per the output convention.
  417. %
  418. % output.bibitem ==
  419. %  BEGIN
  420. %    newline$
  421. %    write$("\bibitem[")    % for alphabetic labels,
  422. %    write$(label)        % these three lines
  423. %    write$("]{")        % are used
  424. %    write$("\bibitem{")        % this line for numeric labels
  425. %    write$(cite$)
  426. %    write$("}")
  427. %    push "" on stack
  428. %    output.state := before.all
  429. %  END
  430. %
  431. % The fin.entry function finishes off an entry by adding a period to the
  432. % string remaining on the stack.  If the state is still before.all
  433. % then nothing was produced for this entry, so the result will look bad,
  434. % but the user deserves it. (We don't omit the whole entry because the
  435. % entry was cited, and a bibitem is needed to define the citation label.)
  436. %
  437. % fin.entry ==
  438. %  BEGIN
  439. %    write$(add.period$(pop()))
  440. %    newline$
  441. %  END
  442. %
  443. % The new.block function prepares for a new block to be output, and
  444. % new.sentence prepares for a new sentence.
  445. %
  446. % new.block ==
  447. %  BEGIN
  448. %    if output.state <> before.all then
  449. %        output.state := after.block
  450. %    fi
  451. %  END
  452. %
  453. % new.sentence ==
  454. %  BEGIN
  455. %    if output.state <> after.block then
  456. %        if output.state <> before.all then
  457. %        output.state :=  after.sentence
  458. %        fi
  459. %    fi
  460. %  END
  461. %
  462. # endif 0
  463.  
  464. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  465.  
  466. FUNCTION {init.state.consts}
  467. { 'before.all #0 :=
  468.   'mid.sentence #1 :=
  469.   'after.sentence #2 :=
  470.   'after.block #3 :=
  471. }
  472.  
  473. # if 0
  474. % the variables s and t are temporary string holders
  475. # endif 0
  476.  
  477. STRINGS { s t }
  478.  
  479. FUNCTION {output.nonnull}
  480. { 's swap$ :=
  481.   output.state mid.sentence =
  482.     { ", " * write$ }
  483.     { output.state after.block =
  484.     { add.period$ write$
  485.       newline$
  486.       "\newblock " write$
  487.     }
  488.     { output.state before.all =
  489.         'write$
  490.         { add.period$ " " * write$ }
  491.       if$
  492.     }
  493.       if$
  494.     }
  495.   if$
  496.   'output.state mid.sentence :=
  497.   s
  498. }
  499.  
  500. FUNCTION {output}
  501. { 's swap$ :=
  502.   s "" =
  503.     'skip$
  504.     { s output.nonnull }
  505.   if$
  506. }
  507.  
  508. FUNCTION {output.check}
  509. { 's swap$ :=
  510.   't swap$ :=
  511.   s "" =
  512.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$ }
  513.     { s output.nonnull }
  514.   if$
  515. }
  516.  
  517. FUNCTION {output.bibitem}
  518. { newline$
  519. #if LAB_ALPH
  520.   "\bibitem[" write$
  521.   label write$
  522.   "]{" write$
  523. #else
  524.   "\bibitem{" write$
  525. #endif
  526.   cite$ write$
  527.   "}" write$
  528.   newline$
  529.   ""
  530.   'output.state before.all :=
  531. }
  532.  
  533. # if 0
  534. % This function finishes all entries.  Note: For an otherwise empty entry
  535. % (which is probably due to a user error) this function prints a
  536. period
  537. # endif 0
  538.  
  539. FUNCTION {fin.entry}
  540. { add.period$
  541.   write$
  542.   newline$
  543. }
  544.  
  545. FUNCTION {new.block}
  546. { output.state before.all =
  547.     'skip$
  548.     { 'output.state after.block := }
  549.   if$
  550. }
  551.  
  552. # if 0
  553. % This function isn't used in these styles
  554. # endif 0
  555.  
  556. FUNCTION {new.sentence}
  557. { output.state after.block =
  558.     'skip$
  559.     { output.state before.all =
  560.     'skip$
  561.     { 'output.state after.sentence := }
  562.       if$
  563.     }
  564.   if$
  565. }
  566.  
  567. # if 0
  568. % These three functions pop one or two (integer) arguments from the stack
  569. % and push a single one, either 0 or 1.
  570. % The 'skip$ in the `and' and `or' functions are used because
  571. % the corresponding if$ would be idempotent
  572. # endif 0
  573.  
  574. FUNCTION {not}
  575. {   { #0 }
  576.     { #1 }
  577.   if$
  578. }
  579.  
  580. FUNCTION {and}
  581. {   'skip$
  582.     { pop$ #0 }
  583.   if$
  584. }
  585.  
  586. FUNCTION {or}
  587. {   { pop$ #1 }
  588.     'skip$
  589.   if$
  590. }
  591.  
  592. # if 0
  593. % Here are some functions for formatting chunks of an entry.
  594. % By convention they either produce a string that can be followed by
  595. % a comma or period (using add.period$, so it is OK to end in a period),
  596. % or they produce the null string.
  597. %
  598. % A useful utility is the field.or.null function, which checks if the
  599. % argument is the result of pushing a `missing' field (one for which no
  600. % assignment was made when the current entry was read in from the database),
  601. % and returns the null string if so, otherwise it returns the field string.
  602. %
  603. % field.or.null(s) ==
  604. %  BEGIN
  605. %    if missing$(s) then return ""
  606. %    else return s
  607. %  END
  608. %
  609. % Another helper function is italicize, which returns the string that
  610. % italicizes the argument string, if that is non-null, otherwise it
  611. % returns the null string.  Italic corrections aren't used, so this
  612. % function should be used when punctation will follow the result.
  613. % Also, it needn't be \em (instead of \it) because the user shouldn't be
  614. % emphasizing the whole bibliography.
  615. %
  616. % italicize(s) ==
  617. %  BEGIN
  618. %    if s = "" then return ""
  619. %    else return "{\it " * s * "}"
  620. %
  621. % The format.names function formats the argument (which should be in
  622. % BibTeX name format) into "First Von~Last, Junior", separated by commas
  623. % and with an "and" before the last (but ending with "et al." if the last
  624. % of multiple authors is "others")
  625. %
  626. % VAR: nameptr, namesleft, numnames: INTEGER
  627. %      nameresult: STRING
  628. %
  629. % format.names(s) ==
  630. %  BEGIN
  631. %    nameptr := 1
  632. %    nameresult := ""
  633. %    numnames := num.names$(s)
  634. %    namesleft := numnames
  635. %    while namesleft > 0
  636. %      do
  637. %                % for full names:
  638. %        t := format.name$(s, nameptr, "{ff }{vv~}{ll}{, jj}")
  639. %                % for abbreviated first names:
  640. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  641. %        if nameptr > 1 then
  642. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  643. %        else if numnames > 2
  644. %               then nameresult := nameresult * ","
  645. %             fi
  646. %             if t = "others"
  647. %               then nameresult := nameresult * " et al."
  648. %               else nameresult := nameresult * " and " * t
  649. %             fi
  650. %        fi
  651. %        else nameresult := nameresult * t
  652. %        fi
  653. %        nameptr := nameptr + 1
  654. %        namesleft := namesleft - 1
  655. %      od
  656. %    return nameresult
  657. %  END
  658. %
  659. % The format.authors function returns the result of format.names(author)
  660. % if the author is present, or else it returns the null string
  661. %
  662. % format.authors ==
  663. %  BEGIN
  664. %    if missing$(author) then return ""
  665. %    else return format.names(author)
  666. %    fi
  667. %  END
  668. %
  669. % Format.editors is like format.authors, but it uses the editor field,
  670. % and appends ", editor" or ", editors"
  671. %
  672. % format.editors ==
  673. %  BEGIN
  674. %    if missing$(editor) then return ""
  675. %    else
  676. %        if num.names$(editor) > 1 then
  677. %        return format.names(editor) * ", editors"
  678. %        else
  679. %        return format.names(editor) * ", editor"
  680. %        fi
  681. %    fi
  682. %  END
  683. %
  684. % Other formatting functions are similar, so no "comment version" will be
  685. % given for them.
  686. %
  687. % The `pop$' in this function gets rid of the duplicate `missing' value and
  688. % the `skip$' returns the duplicate field value
  689. # endif 0
  690.  
  691. FUNCTION {field.or.null}
  692. { duplicate$
  693.   missing$
  694.     { pop$ "" }
  695.     'skip$
  696.   if$
  697. }
  698.  
  699. FUNCTION {italicize}
  700. { 's swap$ :=
  701.   s "" =
  702.     { "" }
  703.     { "{\it " s * "}" * }
  704.   if$
  705. }
  706.  
  707. INTEGERS { nameptr namesleft numnames }
  708.  
  709. STRINGS {nameresult}
  710.  
  711. FUNCTION {format.names}
  712. { 's swap$ :=
  713.   'nameptr #1 :=
  714.   'nameresult "" :=
  715.   'numnames s num.names$ :=
  716.   'namesleft numnames :=
  717.     { namesleft #0 > }
  718.     {
  719. #if NAME_FULL
  720.       't s nameptr "{ff }{vv~}{ll}{, jj}" format.name$ :=
  721. #else
  722.       't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  723. #endif
  724.       nameptr #1 >
  725.     { namesleft #1 >
  726.         { 'nameresult nameresult ", " * t * := }
  727.         { numnames #2 >
  728.         { 'nameresult nameresult "," * := }
  729.         'skip$
  730.           if$
  731.           t "others" =
  732.         { 'nameresult nameresult " et al." * := }
  733. #ifndef FRENCH
  734.         { 'nameresult nameresult " and " * t * := }
  735. #else FRENCH
  736.         { 'nameresult nameresult " et " * t * := }
  737. #endif FRENCH
  738.           if$
  739.         }
  740.       if$
  741.     }
  742.     { 'nameresult nameresult t * := }
  743.       if$
  744.       'nameptr nameptr #1 + :=
  745.       'namesleft namesleft #1 - :=
  746.     }
  747.   while$
  748.   nameresult
  749. }
  750.  
  751. FUNCTION {format.authors}
  752. { author missing$
  753.     { "" }
  754.     { author format.names }
  755.   if$
  756. }
  757.  
  758. FUNCTION {format.editors}
  759. { editor missing$
  760.     { "" }
  761.     { editor num.names$ #1 >
  762. #ifndef FRENCH
  763.     { editor format.names ", editors" * }
  764.     { editor format.names ", editor" * }
  765. #else FRENCH
  766.     { editor format.names ", \'{e}diteurs" * }
  767.     { editor format.names ", \'{e}diteur" * }
  768. #endif FRENCH
  769.       if$
  770.     }
  771.   if$
  772. }
  773.  
  774. # if 0
  775. % The format.title function is used for non-book-like titles.
  776. % For most styles we convert to lowercase (except for the very first letter),
  777. % and hope the user has brace-surrounded words that need to stay capitilized;
  778. % for some, however, we leave it as it is in the database.
  779. # endif 0
  780.  
  781. FUNCTION {format.title}
  782. #if ATIT_LOWER
  783. { title missing$
  784.     { "" }
  785.     { title "ul" change.case$ }
  786.   if$
  787. #else
  788. { title field.or.null
  789. #endif ATIT_LOWER
  790. }
  791.  
  792. # if 0
  793. % The entry.string.max function is set to BibTeX's ent_str_size constant,
  794. % the maximum length of an entry string variable.
  795. %
  796. % The global.string.max function is set to BibTeX's glob_str_size constant,
  797. % the maximum length of a global string variable.
  798. # endif 0
  799.  
  800. FUNCTION {entry.string.max} { #100 }
  801.  
  802. FUNCTION {global.string.max} { #300 }
  803.  
  804. # if 0
  805. % The n.dashify function makes each single `-' in a string a double `--'
  806. % if it's not already
  807. %
  808. % VAR: pageresult: STRING
  809. %
  810. % n.dashify(s) ==
  811. %  BEGIN
  812. %    t := s
  813. %    pageresult := ""
  814. %    while (not (t = ""))
  815. %      do
  816. %        if (first character of t = "-")
  817. %          then
  818. %        if (next character isn't)
  819. %          then
  820. %            pageresult := pageresult * "--"
  821. %            t := t with the "-" removed
  822. %          else
  823. %            while (first character of t = "-")
  824. %              do
  825. %            pageresult := pageresult * "-"
  826. %            t := t with the "-" removed
  827. %              od
  828. %        fi
  829. %          else
  830. %        pageresult := pageresult * the first character
  831. %        t := t with the first character removed
  832. %        fi
  833. %      od
  834. %    return pageresult
  835. %  END
  836. # endif 0
  837.  
  838. STRINGS {pageresult}
  839.  
  840. FUNCTION {n.dashify}
  841. { 't swap$ :=
  842.   'pageresult "" :=
  843.     { t "" = not }
  844.     { t #1 #1 substring$ "-" =
  845.     { t #1 #2 substring$ "--" = not
  846.         { 'pageresult pageresult "--" * :=
  847.           't t #2 global.string.max substring$ :=
  848.         }
  849.         {   { t #1 #1 substring$ "-" = }
  850.         { 'pageresult pageresult "-" * :=
  851.           't t #2 global.string.max substring$ :=
  852.         }
  853.           while$
  854.         }
  855.       if$
  856.     }
  857.     { 'pageresult pageresult t #1 #1 substring$ * :=
  858.       't t #2 global.string.max substring$ :=
  859.     }
  860.       if$
  861.     }
  862.   while$
  863.   pageresult
  864. }
  865.  
  866. # if 0
  867. % The format.date function is for the month and year, but we give a warning if
  868. % there's a missing year but the month is there, and we return the empty string
  869. % if they're both missing
  870. # endif 0
  871.  
  872. FUNCTION {format.date}
  873. { year missing$
  874.     { month missing$
  875.     { "" }
  876.     { "Warning: there's a month but no year in " cite$ * top$
  877.       month
  878.     }
  879.       if$
  880.     }
  881.     { month missing$
  882.     { year }
  883.     { month " " * year * }
  884.       if$
  885.     }
  886.   if$
  887. }
  888.  
  889. # if 0
  890. % The format.btitle is for formatting the title field when it is a book-like
  891. % entry---the style used here keeps it in uppers-and-lowers and italicizes it.
  892. # endif 0
  893.  
  894. FUNCTION {format.btitle}
  895. { title field.or.null
  896.   italicize
  897. }
  898.  
  899. # if 0
  900. % The format.bvolume function is for formatting the volume number and/or
  901. % series name of a multivolume book.  If the volume field is missing, we
  902. % output either the series field italicized if it exists or the null string
  903. % otherwise.  If both the volume and series fields are there, we assume the
  904. % series field is the title of the whole multivolume work (the title field
  905. % should be the title of the one referred to), and add an "of <series>".
  906. % A tie (~) is put between the "Volume" and the volume number.
  907. % We capitilize Volume because this function is used at the beginning of a
  908. % block.
  909. # endif 0
  910.  
  911. FUNCTION {format.bvolume}
  912. { volume missing$
  913.     { series missing$
  914.     { "" }
  915.     { series italicize }
  916.       if$
  917.     }
  918.     { "Volume~" volume *
  919.       series missing$
  920.     'skip$
  921. #ifndef FRENCH
  922.     { " of " * series italicize * }
  923. #else FRENCH
  924.     { ", s\'{e}rie " * series italicize * }
  925. #endif FRENCH
  926.       if$
  927.     }
  928.   if$
  929. }
  930.  
  931. # if 0
  932. % The format.edition function appends " edition" to the edition, if present.
  933. % We lowercase the edition (it should be something like "Third"), because
  934. % this doesn't start a sentence.
  935. # endif 0
  936.  
  937. FUNCTION {format.edition}
  938. { edition missing$
  939.     { "" }
  940. #ifndef FRENCH
  941.     { edition "ll" change.case$ " edition" * }
  942. #else FRENCH
  943.     { edition "ll" change.case$ " \'{e}dition" * }
  944. #endif FRENCH
  945.   if$
  946. }
  947.  
  948. # if 0
  949. % The format.pages function is used for formatting a page range in a book
  950. % (and in rare circumstances, an article).
  951. % The multi.page.check function examines the page field for a "-" or a ","
  952. % so that format.pages can use "page" instead of "pages" if neither exists.
  953. % Note: global.string.max, set above, here means "take the rest of the string"
  954. %
  955. % VAR: multiresult: INTEGER    (actually, a boolean)
  956. %
  957. % multi.page.check(s) ==
  958. %  BEGIN
  959. %    t := s
  960. %    multiresult := false
  961. %    while ((not multiresult) and (not (t = "")))
  962. %      do
  963. %        if (first character of t = "-" or ",")
  964. %          then multiresult := true
  965. %          else t := t with the first character removed
  966. %        fi
  967. %      od
  968. %    return multiresult
  969. %  END
  970. # endif 0
  971.  
  972. INTEGERS {multiresult}
  973.  
  974. FUNCTION {multi.page.check}
  975. { 't swap$ :=
  976.   'multiresult #0 :=
  977.     { multiresult not
  978.       t "" = not
  979.       and
  980.     }
  981.     { t #1 #1 substring$ "-" =
  982.       t #1 #1 substring$ "," =
  983.       or
  984.     { 'multiresult #1 := }
  985.     { 't t #2 global.string.max substring$ := }
  986.       if$
  987.     }
  988.   while$
  989.   multiresult
  990. }
  991.  
  992. # if 0
  993. % This function doesn't begin a sentence so "pages" isn't capitalized
  994. % other functions that use this should keep that in mind
  995. # endif 0
  996.  
  997. FUNCTION {format.pages}
  998. { pages missing$
  999.     { "" }
  1000.     { pages multi.page.check
  1001.     { "pages~" pages n.dashify * }
  1002.     { "page~" pages n.dashify * }
  1003.       if$
  1004.     }
  1005.   if$
  1006. }
  1007.  
  1008. # if 0
  1009. % The format.vol.num.pages function is for the volume, number, and page range
  1010. % of a journal article.  We use the format:  vol(number):pages, with minor
  1011. % variations for missing fields.  This doesn't begin a sentence.
  1012. # endif 0
  1013.  
  1014. FUNCTION {format.vol.num.pages}
  1015. { volume field.or.null
  1016.   number missing$
  1017.     'skip$
  1018.     { "(" number * ")" * *
  1019.       volume missing$
  1020.     { "Warning: there's a number but no volume in " cite$ * top$ }
  1021.     'skip$
  1022.       if$
  1023.     }
  1024.   if$
  1025.   pages missing$
  1026.     'skip$
  1027.     { duplicate$ "" =
  1028.     'skip$
  1029.     { ":" * }
  1030.       if$
  1031.       pages n.dashify *
  1032.     }
  1033.   if$
  1034. }
  1035.  
  1036. # if 0
  1037. % The format.chapter.pages puts "chapter~" in front of a chapter number,
  1038. % if present, and then appends the pages, if present.
  1039. % This doesn't begin a sentence.
  1040. # endif 0
  1041.  
  1042. FUNCTION {format.chapter.pages}
  1043. { chapter missing$
  1044.     'format.pages
  1045. #ifndef FRENCH
  1046.     { "chapter~" chapter *
  1047. #else FRENCH
  1048.     { "chapitre~" chapter *
  1049. #endif FRENCH
  1050.       pages missing$
  1051.     'skip$
  1052.     { ", " * format.pages * }
  1053.       if$
  1054.     }
  1055.   if$
  1056. }
  1057.  
  1058. # if 0
  1059. % The format.in.ed.booktitle function is used for starting out a sentence
  1060. % that begins "In <booktitle>", putting an editor before the title if one
  1061. % exists.
  1062. # endif 0
  1063.  
  1064. FUNCTION {format.in.ed.booktitle}
  1065. { booktitle missing$
  1066.     { "" }
  1067.     { 's format.editors :=
  1068.       s "" =
  1069. #ifndef FRENCH
  1070.     { "In " booktitle italicize * }
  1071.     { "In " s * ", " * booktitle italicize * }
  1072. #else FRENCH
  1073.     { "Dans " booktitle italicize * }
  1074.     { "Dans " s * ", " * booktitle italicize * }
  1075. #endif FRENCH
  1076.       if$
  1077.     }
  1078.   if$
  1079. }
  1080.  
  1081. # if 0
  1082. % The format.tr.number makes a string starting with "Technical Report"
  1083. % (or type, if that field is defined), followed by the number if there
  1084. % is one (but return the first part even if there is no number)
  1085. # endif 0
  1086.  
  1087. FUNCTION {format.tr.number}
  1088. { type missing$
  1089. #ifndef FRENCH
  1090.     { "Technical Report" }
  1091. #else FRENCH
  1092.     { "Rapport" }
  1093. #endif FRENCH
  1094.     { type }
  1095.   if$
  1096.   number missing$
  1097.     'skip$
  1098. #ifndef FRENCH
  1099.     { "~" * number * }
  1100. #else FRENCH
  1101.     { " no.~" * number * }
  1102. #endif FRENCH
  1103.   if$
  1104. }
  1105.  
  1106. # if 0
  1107. % Now we define the type functions for all entry types that may appear
  1108. % in the .BIB file---e.g., functions like `book' and `article'.  These
  1109. % are the routines that actually generate the .BBL-file output for
  1110. % the entry.  These must all precede the READ command.  In addition, the
  1111. % style designer should have a function `default.type' for unknown types.
  1112. % Note: The fields (within each list) are listed in order of appearance,
  1113. % except as described for a `proceedings'.
  1114. %
  1115. % The article function is for an article in a journal.
  1116. %    Required fields: author, title, journal, year
  1117. %    Optional fields: volume, number, pages, month, note
  1118. %
  1119. % article ==
  1120. %  BEGIN
  1121. %    output.bibitem
  1122. %    output.check("author",format.authors)
  1123. %    new.block
  1124. %    output.check("title",format.title)
  1125. %    new.block
  1126. %    output.check("journal",italicize(field.or.null(journal)))
  1127. %    output(format.vol.num.pages)
  1128. %    output.check("year",format.date)
  1129. %    new.block
  1130. %    output(field.or.null(note))
  1131. %    fin.entry
  1132. %  END
  1133. %
  1134. % The book function is for a whole book.
  1135. %    Required fields: author or editor, title, publisher, year
  1136. %    Optional fields: volume, series, address, edition, month, note
  1137. %
  1138. % book ==
  1139. %  BEGIN
  1140. %    if missing$(author) then output.check("author and editor",
  1141. %                                format.editors)
  1142. %    else output.check("author",format.authors)
  1143. %    fi
  1144. %    new.block
  1145. %    output.check("title",format.btitle)
  1146. %    new.block
  1147. %    output(format.bvolume)
  1148. %    output.check("publisher",field.or.null(publisher))
  1149. %    output(field.or.null(address))
  1150. %    output(format.edition)
  1151. %    output.check("year",format.date))
  1152. %    new.block
  1153. %    output(field.or.null(note))
  1154. %    fin.entry
  1155. %  END
  1156. %
  1157. % The other entry functions are all quite similar, so no "comment version"
  1158. % will be given for them.
  1159. # endif 0
  1160.  
  1161. FUNCTION {article}
  1162. { output.bibitem
  1163.   "author" format.authors output.check
  1164.   new.block
  1165.   "title" format.title output.check
  1166.   new.block
  1167.   "journal" journal field.or.null italicize output.check
  1168.   format.vol.num.pages output
  1169.   "year" format.date output.check
  1170.   new.block
  1171.   note field.or.null output
  1172.   fin.entry
  1173. }
  1174.  
  1175. FUNCTION {book}
  1176. { output.bibitem
  1177.   author missing$
  1178.     { "author and editor" format.editors output.check }
  1179.     { "author" format.authors output.check }
  1180.   if$
  1181.   new.block
  1182.   "title" format.btitle output.check
  1183.   new.block
  1184.   format.bvolume output
  1185.   "publisher" publisher field.or.null output.check
  1186.   address field.or.null output
  1187.   format.edition output
  1188.   "year" format.date output.check
  1189.   new.block
  1190.   note field.or.null output
  1191.   fin.entry
  1192. }
  1193.  
  1194. # if 0
  1195. % A booklet is a bound thing without a publisher or sponsoring institution
  1196. %    Required: title
  1197. %    Optional: author, howpublished, address, month, year, note
  1198. # endif 0
  1199.  
  1200. FUNCTION {booklet}
  1201. { output.bibitem
  1202.   format.authors output
  1203.   new.block
  1204.   "title" format.btitle output.check
  1205.   new.block
  1206.   howpublished field.or.null output
  1207.   address field.or.null output
  1208.   format.date output
  1209.   new.block
  1210.   note field.or.null output
  1211.   fin.entry
  1212. }
  1213.  
  1214. # if 0
  1215. % For the conference entry type, see inproceedings
  1216. # endif 0
  1217.  
  1218. # if 0
  1219. % An inbook is a piece of a book: either a chapter and/or a page range.
  1220. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1221. %    Optional: volume, series, address, edition, month, note
  1222. # endif 0
  1223.  
  1224. FUNCTION {inbook}
  1225. { output.bibitem
  1226.   author missing$
  1227.     { "author and editor" format.editors output.check }
  1228.     { "author" format.authors output.check }
  1229.   if$
  1230.   new.block
  1231.   "title" format.btitle output.check
  1232.   "chapter and pages" format.chapter.pages output.check
  1233.   new.block
  1234.   format.bvolume output
  1235.   "publisher" publisher field.or.null output.check
  1236.   address field.or.null output
  1237.   format.edition output
  1238.   "year" format.date output.check
  1239.   new.block
  1240.   note field.or.null output
  1241.   fin.entry
  1242. }
  1243.  
  1244. # if 0
  1245. % An incollection is like inbook, but where there is a separate title
  1246. % for the referenced thing (and perhaps an editor for the whole)
  1247. %    Required: author, title, booktitle, publisher, year
  1248. %    Optional: editor, chapter, pages, address, month, note
  1249. # endif 0
  1250.  
  1251. FUNCTION {incollection}
  1252. { output.bibitem
  1253.   "authors" format.authors output.check
  1254.   new.block
  1255.   "title" format.title output.check
  1256.   new.block
  1257.   "booktitle" format.in.ed.booktitle output.check
  1258.   format.chapter.pages output
  1259.   "publisher" publisher field.or.null output.check
  1260.   address field.or.null output
  1261.   "year" format.date output.check
  1262.   new.block
  1263.   note field.or.null output
  1264.   fin.entry
  1265. }
  1266.  
  1267. # if 0
  1268. % An inproceedings is an article in a conference proceedings
  1269. %    Required: author, title, booktitle, year
  1270. %    Optional: editor, pages, organization, publisher, address, month, note
  1271. # endif 0
  1272.  
  1273. FUNCTION {inproceedings}
  1274. { output.bibitem
  1275.   "author" format.authors output.check
  1276.   new.block
  1277.   "title" format.title output.check
  1278.   new.block
  1279.   "booktitle" format.in.ed.booktitle output.check
  1280.   format.pages output
  1281.   organization field.or.null output
  1282.   publisher field.or.null output
  1283.   address field.or.null output
  1284.   "year" format.date output.check
  1285.   new.block
  1286.   note field.or.null output
  1287.   fin.entry
  1288. }
  1289.  
  1290. # if 0
  1291. % The conference function is included for Scribe compatibility
  1292. # endif 0
  1293.  
  1294. FUNCTION {conference} { inproceedings }
  1295.  
  1296. # if 0
  1297. % A manual is technical documentation
  1298. %    Required: title
  1299. %    Optional: author, organization, address, edition, month, year, note
  1300. # endif 0
  1301.  
  1302. FUNCTION {manual}
  1303. { output.bibitem
  1304.   format.authors output
  1305.   new.block
  1306.   "title" format.btitle output.check
  1307.   new.block
  1308.   organization field.or.null output
  1309.   address field.or.null output
  1310.   format.edition output
  1311.   format.date output
  1312.   new.block
  1313.   note field.or.null output
  1314.   fin.entry
  1315. }
  1316.  
  1317. # if 0
  1318. % A mastersthesis is a Master's thesis
  1319. %    Required: author, title, school, year
  1320. %    Optional: address, month, note
  1321. # endif 0
  1322.  
  1323. FUNCTION {mastersthesis}
  1324. { output.bibitem
  1325.   "author" format.authors output.check
  1326.   new.block
  1327.   "title" format.btitle output.check
  1328.   new.block
  1329. #ifndef FRENCH
  1330.   "Master's thesis" output
  1331. #else FRENCH
  1332.   "Rapport de ma\^{\i}trise" output
  1333. #endif FRENCH
  1334.   "school" school field.or.null output.check
  1335.   address field.or.null output
  1336.   "year" format.date output.check
  1337.   new.block
  1338.   note field.or.null output
  1339.   fin.entry
  1340. }
  1341.  
  1342. # if 0
  1343. % added for France: rapport de DEA, like master's thesis
  1344. # endif 0
  1345.  
  1346. FUNCTION {deathesis}
  1347. { output.bibitem
  1348.   "author" format.authors output.check
  1349.   new.block
  1350.   "title" format.btitle output.check
  1351.   new.block
  1352. #ifdef FRENCH
  1353.   "Rapport de DEA" output
  1354. #else
  1355.   "Dipl\^{o}me d'Etudes Approfondies Thesis" output
  1356. #endif FRENCH
  1357.   "school" school field.or.null output.check
  1358.   address field.or.null output
  1359.   "year" format.date output.check
  1360.   new.block
  1361.   note field.or.null output
  1362.   fin.entry
  1363. }
  1364.  
  1365. # if 0
  1366. % a misc is something that doesn't fit elsewhere
  1367. %    Required: none
  1368. %    Optional: author, title, howpublished, month, year, note
  1369. # endif 0
  1370.  
  1371. FUNCTION {misc}
  1372. { output.bibitem
  1373.   format.authors output
  1374.   new.block
  1375.   format.title output
  1376.   new.block
  1377.   howpublished field.or.null output
  1378.   format.date output
  1379.   new.block
  1380.   note field.or.null output
  1381.   fin.entry
  1382. }
  1383.  
  1384. # if 0
  1385. % A phdthesis is like a mastersthesis
  1386. %    Required: author, title, school, year
  1387. %    Optional: address, month, note
  1388. # endif 0
  1389.  
  1390. FUNCTION {phdthesis}
  1391. { output.bibitem
  1392.   "author" format.authors output.check
  1393.   new.block
  1394.   "title" format.btitle output.check
  1395.   new.block
  1396. #ifndef FRENCH
  1397.   "PhD thesis" output
  1398. #else FRENCH
  1399.   "Th\`{e}se de Doctorat" output
  1400. #endif FRENCH
  1401.   "school" school field.or.null output.check
  1402.   address field.or.null output
  1403.   "year" format.date output.check
  1404.   new.block
  1405.   note field.or.null output
  1406.   fin.entry
  1407. }
  1408.  
  1409. # if 0
  1410. % a proceedings is a conference proceedings
  1411. % if there is an organization but no editor field, the organization will
  1412. % appear as the first optional field (we try to make the first block nonempty)
  1413. %    Required: title, year
  1414. %    Optional: editor, publisher, organization, address, month, note
  1415. # endif 0
  1416.  
  1417. FUNCTION {proceedings}
  1418. { output.bibitem
  1419.   editor missing$
  1420.     { organization missing$
  1421.     'skip$
  1422.     { organization field.or.null output }
  1423.       if$
  1424.     }
  1425.     { format.editors output }
  1426.   if$
  1427.   new.block
  1428.   "title" format.btitle output.check
  1429.   editor missing$
  1430.     'skip$
  1431.     { organization field.or.null output }
  1432.   if$
  1433.   publisher field.or.null output
  1434.   address field.or.null output
  1435.   "year" format.date output.check
  1436.   new.block
  1437.   note field.or.null output
  1438.   fin.entry
  1439. }
  1440.  
  1441. # if 0
  1442. % a techreport is a technical report.
  1443. %    Required: author, title, institution, year
  1444. %    Optional: type, number, address, month, note
  1445. # endif 0
  1446.  
  1447. FUNCTION {techreport}
  1448. { output.bibitem
  1449.   "author" format.authors output.check
  1450.   new.block
  1451.   "title" format.btitle output.check
  1452.   new.block
  1453.   format.tr.number output
  1454.   "institution" institution field.or.null output.check
  1455.   address field.or.null output
  1456.   "year" format.date output.check
  1457.   new.block
  1458.   note field.or.null output
  1459.   fin.entry
  1460. }
  1461.  
  1462. # if 0
  1463. % an unpublished is something that hasn't been published
  1464. %    Required: author, title, note
  1465. %    Optional: month, year
  1466. # endif 0
  1467.  
  1468. FUNCTION {unpublished}
  1469. { output.bibitem
  1470.   "author" format.authors output.check
  1471.   new.block
  1472.   "title" format.title output.check
  1473.   new.block
  1474.   format.date output
  1475.   new.block
  1476.   "note" note field.or.null output.check
  1477.   fin.entry
  1478. }
  1479.  
  1480. # if 0
  1481. % We use entry type book for an unknown type and give a warning
  1482. # endif 0
  1483.  
  1484. FUNCTION {default.type} { book }
  1485.  
  1486. # if 0
  1487. % Here are macros for common things that may vary from style to style.
  1488. % Users are encouraged to use these macros.
  1489. %
  1490. % Months are either written out in full or abbreviated
  1491. # endif 0
  1492.  
  1493. #if MONTH_FULL
  1494.  
  1495. #ifndef FRENCH
  1496. MACRO {jan} {"January"}
  1497. #else FRENCH
  1498. MACRO {jan} {"janvier"}
  1499. #endif FRENCH
  1500.  
  1501. #ifndef FRENCH
  1502. MACRO {feb} {"February"}
  1503. #else FRENCH
  1504. MACRO {feb} {"f\'{e}vrier"}
  1505. #endif FRENCH
  1506.  
  1507. #ifndef FRENCH
  1508. MACRO {mar} {"March"}
  1509. #else FRENCH
  1510. MACRO {mar} {"mars"}
  1511. #endif FRENCH
  1512.  
  1513. #ifndef FRENCH
  1514. MACRO {apr} {"April"}
  1515. #else FRENCH
  1516. MACRO {apr} {"avril"}
  1517. #endif FRENCH
  1518.  
  1519. #ifndef FRENCH
  1520. MACRO {may} {"May"}
  1521. #else FRENCH
  1522. MACRO {may} {"mai"}
  1523. #endif FRENCH
  1524.  
  1525. #ifndef FRENCH
  1526. MACRO {jun} {"June"}
  1527. #else FRENCH
  1528. MACRO {jun} {"juin"}
  1529. #endif FRENCH
  1530.  
  1531. #ifndef FRENCH
  1532. MACRO {jul} {"July"}
  1533. #else FRENCH
  1534. MACRO {jul} {"juillet"}
  1535. #endif FRENCH
  1536.  
  1537. #ifndef FRENCH
  1538. MACRO {aug} {"August"}
  1539. #else FRENCH
  1540. MACRO {aug} {"ao\^{u}t"}
  1541. #endif FRENCH
  1542.  
  1543. #ifndef FRENCH
  1544. MACRO {sep} {"September"}
  1545. #else FRENCH
  1546. MACRO {sep} {"septembre"}
  1547. #endif FRENCH
  1548.  
  1549. #ifndef FRENCH
  1550. MACRO {oct} {"October"}
  1551. #else FRENCH
  1552. MACRO {oct} {"octobre"}
  1553. #endif FRENCH
  1554.  
  1555. #ifndef FRENCH
  1556. MACRO {nov} {"November"}
  1557. #else FRENCH
  1558. MACRO {nov} {"novembre"}
  1559. #endif FRENCH
  1560.  
  1561. #ifndef FRENCH
  1562. MACRO {dec} {"December"}
  1563. #else FRENCH
  1564. MACRO {dec} {"d\'{e}cembre"}
  1565. #endif FRENCH
  1566.  
  1567. #else !MONTH_FULL
  1568.  
  1569. #ifndef FRENCH
  1570. MACRO {jan} {"Jan."}
  1571. #else FRENCH
  1572. MACRO {jan} {"jan."}
  1573. #endif FRENCH
  1574.  
  1575. #ifndef FRENCH
  1576. MACRO {feb} {"Feb."}
  1577. #else FRENCH
  1578. MACRO {feb} {"f\'{e}v."}
  1579. #endif FRENCH
  1580.  
  1581. #ifndef FRENCH
  1582. MACRO {mar} {"March"}
  1583. #else FRENCH
  1584. MACRO {mar} {"mars"}
  1585. #endif FRENCH
  1586.  
  1587. #ifndef FRENCH
  1588. MACRO {apr} {"Apr."}
  1589. #else FRENCH
  1590. MACRO {apr} {"avr."}
  1591. #endif FRENCH
  1592.  
  1593. #ifndef FRENCH
  1594. MACRO {may} {"May"}
  1595. #else FRENCH
  1596. MACRO {may} {"mai"}
  1597. #endif FRENCH
  1598.  
  1599. #ifndef FRENCH
  1600. MACRO {jun} {"June"}
  1601. #else FRENCH
  1602. MACRO {jun} {"juin"}
  1603. #endif FRENCH
  1604.  
  1605. #ifndef FRENCH
  1606. MACRO {jul} {"July"}
  1607. #else FRENCH
  1608. MACRO {jul} {"juil."}
  1609. #endif FRENCH
  1610.  
  1611. #ifndef FRENCH
  1612. MACRO {aug} {"Aug."}
  1613. #else FRENCH
  1614. MACRO {aug} {"ao\^{u}t"}
  1615. #endif FRENCH
  1616.  
  1617. #ifndef FRENCH
  1618. MACRO {sep} {"Sep."}
  1619. #else FRENCH
  1620. MACRO {sep} {"sep."}
  1621. #endif FRENCH
  1622.  
  1623. #ifndef FRENCH
  1624. MACRO {oct} {"Oct."}
  1625. #else FRENCH
  1626. MACRO {oct} {"oct."}
  1627. #endif FRENCH
  1628.  
  1629. #ifndef FRENCH
  1630. MACRO {nov} {"Nov."}
  1631. #else FRENCH
  1632. MACRO {nov} {"nov."}
  1633. #endif FRENCH
  1634.  
  1635. #ifndef FRENCH
  1636. MACRO {dec} {"Dec."}
  1637. #else FRENCH
  1638. MACRO {dec} {"d\'{e}c."}
  1639. #endif FRENCH
  1640.  
  1641. #endif MONTH_FULL
  1642.  
  1643. # if 0
  1644. % Journals are either written out in full or abbreviated;
  1645. % the abbreviations are like those found in ACM publications.
  1646. %
  1647. % To get a completely different set of abbreviations, it may be best to make
  1648. % a separate .bib file with nothing but those abbreviations; users could then
  1649. % include that file name as the first argument to the \bibliography command
  1650. # endif 0
  1651.  
  1652. #if JOUR_FULL
  1653.  
  1654. MACRO {acmcs} {"ACM Computing Surveys"}
  1655.  
  1656. MACRO {acta} {"Acta Informatica"}
  1657.  
  1658. MACRO {cacm} {"Communications of the ACM"}
  1659.  
  1660. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  1661.  
  1662. MACRO {ibmsj} {"IBM Systems Journal"}
  1663.  
  1664. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  1665.  
  1666. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  1667.  
  1668. MACRO {ieeetcad}
  1669.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1670.  
  1671. MACRO {ipl} {"Information Processing Letters"}
  1672.  
  1673. MACRO {jacm} {"Journal of the ACM"}
  1674.  
  1675. MACRO {jcss} {"Journal of Computer and System Sciences"}
  1676.  
  1677. MACRO {scp} {"Science of Computer Programming"}
  1678.  
  1679. MACRO {sicomp} {"SIAM Journal on Computing"}
  1680.  
  1681. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  1682.  
  1683. MACRO {tods} {"ACM Transactions on Database Systems"}
  1684.  
  1685. MACRO {tog} {"ACM Transactions on Graphics"}
  1686.  
  1687. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1688.  
  1689. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1690.  
  1691. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1692.  
  1693. MACRO {tcs} {"Theoretical Computer Science"}
  1694.  
  1695. #ifdef FRENCH
  1696. MACRO {tsi} {"Technique et Science Informatiques"}
  1697.  
  1698. #endif FRENCH
  1699. #else !JOUR_FULL
  1700.  
  1701. MACRO {acmcs} {"ACM Comput. Surv."}
  1702.  
  1703. MACRO {acta} {"Acta Inf."}
  1704.  
  1705. MACRO {cacm} {"Commun. ACM"}
  1706.  
  1707. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1708.  
  1709. MACRO {ibmsj} {"IBM Syst. J."}
  1710.  
  1711. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1712.  
  1713. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1714.  
  1715. MACRO {ieeetcad}
  1716.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1717.  
  1718. MACRO {ipl} {"Inf. Process. Lett."}
  1719.  
  1720. MACRO {jacm} {"J. ACM"}
  1721.  
  1722. MACRO {jcss} {"J. Comput. Syst. Sci."}
  1723.  
  1724. MACRO {scp} {"Sci. Comput. Programming"}
  1725.  
  1726. MACRO {sicomp} {"SIAM J. Comput."}
  1727.  
  1728. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1729.  
  1730. MACRO {tods} {"ACM Trans. Database Syst."}
  1731.  
  1732. MACRO {tog} {"ACM Trans. Gr."}
  1733.  
  1734. MACRO {toms} {"ACM Trans. Math. Softw."}
  1735.  
  1736. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1737.  
  1738. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1739.  
  1740. MACRO {tcs} {"Theoretical Comput. Sci."}
  1741.  
  1742. MACRO {tsi} {"Technique et Science Informatiques"}
  1743.  
  1744. #endif JOUR_FULL
  1745.  
  1746. # if 0
  1747. % Now we read in the .BIB entries.
  1748. # endif 0
  1749.  
  1750. READ
  1751.  
  1752. # if 0
  1753. % The sortify function converts to lower case after purify$ing; it's
  1754. % used in sorting and in computing alphabetic labels after sorting
  1755. # endif 0
  1756.  
  1757. #if SORTED
  1758.  
  1759. FUNCTION {sortify}
  1760. { purify$
  1761.   "ll" change.case$
  1762. }
  1763.  
  1764. #endif SORTED
  1765.  
  1766. # if 0
  1767. % This long comment applies only to alphabetic labels
  1768. %
  1769. % The format.lab.names function makes a short label by using the initials of
  1770. % the von and Last parts of the names (but if there are more than four names,
  1771. % (i.e., people) it truncates after three and adds a "*";
  1772. % it also adds a "*" if the last of multiple authors is "others").
  1773. % If there is only one name, and its von and Last parts combined have just
  1774. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1775. % we take the first three letters of the last name.
  1776. % In the LONG and ALPHA3 styles, only the name of the first author is
  1777. % considered.
  1778. % In the KEY and SKEY styles, the label is equal to the citation key.
  1779. %
  1780. % format.lab.names(s) ==
  1781. %  BEGIN
  1782. %    numnames := num.names$(s)
  1783. %    if numnames > 1 then
  1784. %        if numnames > 4 then
  1785. %        namesleft := 3
  1786. %        else
  1787. %        namesleft := numnames
  1788. %        nameptr := 1
  1789. %        nameresult := ""
  1790. %        while namesleft > 0
  1791. %          do
  1792. %        if (name_ptr = numnames) and
  1793. %            format.name$(s, nameptr, "{ff}{vv}{ll}{jj}") = "others"
  1794. %            then nameresult := nameresult * "*"
  1795. %            else nameresult := nameresult *
  1796. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1797. %        nameptr := nameptr + 1
  1798. %        namesleft := namesleft - 1
  1799. %          od
  1800. %        if numnames > 4 then
  1801. %        nameresult := nameresult * "*"
  1802. %    else
  1803. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1804. %        if substring$(t, 2, 1) = "" then    % there's just one name-token
  1805. %        nameresult := substring$(purify$(format.name$(s, 1, "{ll}")),
  1806. %                                    1, 3)
  1807. %        else
  1808. %        nameresult := t
  1809. %        fi
  1810. %    fi
  1811. %    nameresult
  1812. %  END
  1813. %
  1814. % Here is a function for calculating the preliminary label of an entry.
  1815. % It is formed by calculating format.lab.names on the author field
  1816. % (or on the editor field if there is no author, or using the first three
  1817. % letters of the key field if there is no editor either), and appending the
  1818. % last two characters (digits) of the year.  It is an error if there is no
  1819. % author, editor or key field, and we use the first three letters of the title
  1820. % in desperation when this happens.  The resulting label is purify$ed, except
  1821. % for possibly a "*" if there are too many authors.
  1822. %
  1823. % This function also calculates the version of this label to be used in sorting
  1824. %
  1825. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1826. % otherwise identical labels, but we can't calculated those "extra.label"s
  1827. % until after sorting.
  1828. %
  1829. % calc.label ==
  1830. %  BEGIN
  1831. %    if missing$(author) then
  1832. %        if missing$(editor) then
  1833. %        if missing$(key) then
  1834. %            top$("Warning: need a key to make a label in " * cite$)
  1835. %            label := substring$(purify$(field.or.null(title)), 1, 3)
  1836. %        else
  1837. %            label := substring$(purify$(key), 1, 3)
  1838. %        fi
  1839. %        else
  1840. %        label := format.lab.names(editor)
  1841. %        fi
  1842. %    else
  1843. %        label := format.lab.names(author)
  1844. %    fi
  1845. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1846. %        % assuming we will also sort, we calculate a sort.label
  1847. %    sort.label := sortify(label)
  1848. %  END
  1849. %
  1850. % In the case of the SKEY style, compute the sort.label as above, but do
  1851. %       label := cite$
  1852. % In the case of the KEY style, the above computation is done but not used.
  1853. % It really should be taken out, but what the heck.
  1854. # endif 0
  1855.  
  1856. #if LAB_ALPH
  1857.  
  1858. FUNCTION {format.lab.names}
  1859. { 's swap$ :=
  1860. #if !ALPHA_LONG
  1861.   'numnames s num.names$ :=
  1862.   numnames #1 >
  1863.     { numnames #4 >
  1864.     { 'namesleft #3 := }
  1865.     { 'namesleft numnames := }
  1866.       if$
  1867.       'nameptr #1 :=
  1868.       'nameresult "" :=
  1869.     { namesleft #0 > }
  1870.     { nameptr numnames =
  1871.         { s nameptr "{ff}{vv}{ll}{jj}" format.name$ "others" =
  1872.         { 'nameresult nameresult "*" * := }
  1873.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1874.           * :=
  1875.         }
  1876.           if$
  1877.         }
  1878.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1879.           * :=
  1880.         }
  1881.       if$
  1882.       'nameptr nameptr #1 + :=
  1883.       'namesleft namesleft #1 - :=
  1884.     }
  1885.       while$
  1886.       numnames #4 >
  1887.     { 'nameresult nameresult "*" * := }
  1888.     'skip$
  1889.       if$
  1890.     }
  1891.     { 
  1892. #endif ALPHA_LONG
  1893.  
  1894.       't s #1 "{v{}}{l{}}" format.name$ :=
  1895.  
  1896.       'nameresult
  1897.       t #2 #1 substring$ "" =
  1898.  
  1899. #if ALPHA_LONG<2
  1900.     { s #1 "{ll}" format.name$ purify$ #1 #3 substring$ }
  1901. #else ALPHA_LONG
  1902.         { s #1 "{ll}" format.name$ purify$ }
  1903. #endif ALPHA_LONG
  1904.  
  1905.     { t }
  1906.       if$
  1907.       :=
  1908.  
  1909. #if !ALPHA_LONG
  1910.     }
  1911.   if$
  1912. #endif ALPHA_LONG
  1913.  
  1914.   nameresult
  1915. }
  1916.  
  1917. FUNCTION {calc.label}
  1918. { 'label
  1919.   author missing$
  1920.     { editor missing$
  1921.     { key missing$
  1922.         { "Warning: need a key to make a label in " cite$ * top$
  1923.           title field.or.null purify$ #1 #3 substring$
  1924.         }
  1925.         { key purify$ #1 #3 substring$ }
  1926.       if$
  1927.     }
  1928.     { editor format.lab.names }
  1929.       if$
  1930.     }
  1931.     { author format.lab.names }
  1932.   if$
  1933. #ifdef ALPHA_LONG>1
  1934.   " " year field.or.null purify$ #-1 #2 substring$ *
  1935. #else ALPHA_LONG
  1936.   year field.or.null purify$ #-1 #2 substring$
  1937. #endif ALPHA_LONG
  1938.   *
  1939.   :=
  1940. #if SORTED
  1941.   'sort.label label sortify :=
  1942. #endif SORTED
  1943. #if LBKEYS
  1944.   'label cite$ :=
  1945. #endif LBKEYS
  1946. }
  1947.  
  1948. # if 0
  1949. % It doesn't seem like a particularly good idea to use an order-of-citation
  1950. % reference list when using alphabetic labels, but we need to have a
  1951. % special pass to calculate labels when this happens.
  1952. # endif 0
  1953.  
  1954. #if !SORTED
  1955.  
  1956. ITERATE {calc.label}
  1957.  
  1958. #endif !SORTED
  1959.  
  1960. #endif LAB_ALPH
  1961.  
  1962. # if 0
  1963. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1964. % The presort key contains a number of "sortify"ed strings, concatenated
  1965. % with multiple blanks between them.  This makes things like "brinch  per"
  1966. % come before "brinch hansen  per"
  1967. %
  1968. % The fields used here are:
  1969. % the sort.label for alphabetic labels (as set by calc.label),
  1970. % followed by the author names (or editor names, if those are missing,
  1971. % or the key field if both are), followed by the first bit
  1972. % of the title (chopping off a leading "The ", "A ", or "An ").
  1973. % Names are formatted: Von Last First Junior.
  1974. % The names within a part will be separated by a single blank
  1975. % (such as "brinch hansen"), two will separate the name parts themselves
  1976. % (except the von and last), three will separate the names,
  1977. % and four will separate the names from the title (and label, if alphabetic).
  1978. %
  1979. % The sort.format.names function takes an argument that should be in
  1980. % BibTeX name format, and returns a string containing "   "-separated
  1981. % names in the format described above.  The function is almost the same
  1982. % as format.names.
  1983. # endif 0
  1984.  
  1985. #if SORTED
  1986.  
  1987. FUNCTION {sort.format.names}
  1988. { 's swap$ :=
  1989.   'nameptr #1 :=
  1990.   'nameresult "" :=
  1991.   'numnames s num.names$ :=
  1992.   'namesleft numnames :=
  1993.     { namesleft #0 > }
  1994.     { nameptr #1 >
  1995.     { 'nameresult nameresult "   " * := }
  1996.     'skip$
  1997.       if$
  1998. #if NAME_FULL
  1999.       't s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ :=
  2000. #else
  2001.       't s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ :=
  2002. #endif NAME_FULL
  2003.       nameptr numnames = t "others" = and
  2004.     { 'nameresult nameresult "et al" * := }
  2005.     { 'nameresult nameresult t sortify * := }
  2006.       if$
  2007.       'nameptr nameptr #1 + :=
  2008.       'namesleft namesleft #1 - :=
  2009.     }
  2010.   while$
  2011.   nameresult
  2012. }
  2013.  
  2014. # if 0
  2015. % The chop.word(w,len,s) function returns either s or, if the first len
  2016. % letters of s equals w (this comparison is done in the third line of the
  2017. % function's definition), it returns that part of s after w.
  2018. # endif 0
  2019.  
  2020. INTEGERS {len}
  2021.  
  2022. FUNCTION {chop.word}
  2023. { 's swap$ :=
  2024.   'len swap$ :=
  2025.   s #1 len substring$ =
  2026.     { s len #1 + global.string.max substring$ }
  2027.     { s }
  2028.   if$
  2029. }
  2030.  
  2031. # if 0
  2032. % The sort.format.title function returns the argument,
  2033. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  2034. % The chop.word function uses s, so we need another string variable, t
  2035. # endif 0
  2036.  
  2037. FUNCTION {sort.format.title}
  2038. { 't swap$ :=
  2039.   "A " #2
  2040.     "An " #3
  2041.       "The " #4 t chop.word
  2042.     chop.word
  2043.   chop.word
  2044.   #1 global.string.max substring$
  2045.   sortify
  2046. }
  2047.  
  2048. # if 0
  2049. % There is a limit on the length of an entry string variable, which
  2050. % is what its sort.key$ is.  The limit is currently entry.string.max, so we
  2051. % take at most that many characters of the constructed key, and hope
  2052. % there aren't many references that match to that many characters!
  2053. # endif 0
  2054.  
  2055. FUNCTION {presort}
  2056. {
  2057. #if LAB_ALPH
  2058.   calc.label
  2059.   sort.label
  2060.   "    "
  2061.   *
  2062. #endif LAB_ALPH
  2063.   author missing$
  2064.     { editor missing$
  2065.     { key field.or.null sortify }
  2066.     { editor sort.format.names }
  2067.       if$
  2068.     }
  2069.     { author sort.format.names }
  2070.   if$
  2071. #if LAB_ALPH
  2072.   *
  2073. #endif LAB_ALPH
  2074.   "    "
  2075.   *
  2076.   title field.or.null
  2077.   sort.format.title
  2078.   *
  2079.   #1 entry.string.max substring$
  2080.   'sort.key$ swap$ :=
  2081. }
  2082.  
  2083. ITERATE {presort}
  2084.  
  2085. # if 0
  2086. % And now we can sort
  2087. # endif 0
  2088.  
  2089. SORT
  2090.  
  2091. #endif SORTED
  2092.  
  2093. # if 0
  2094. % This long comment applies only to alphabetic labels, when sorted
  2095. %
  2096. % Now comes the final computation for alphabetic labels, putting in the 'a's
  2097. % and 'b's and so forth if required.  This involves two passes: a forward
  2098. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  2099. % to put in the 'a's (we don't want to put in 'a's unless we know there
  2100. % are 'b's).
  2101. % We have to keep track of the longest (in width$ terms) label, for use
  2102. % by the "thebibliography" environment.
  2103. %
  2104. % VAR: longest.label, last.sort.label, next.extra: string
  2105. %      longest.label.width, last.extra.num: integer
  2106. %
  2107. % initialize.longest.label ==
  2108. %  BEGIN
  2109. %    longest.label := ""
  2110. %    last.sort.label := ""
  2111. %    next.extra := ""
  2112. %    longest.label.width := 0
  2113. %    last.extra.num := 0
  2114. %  END
  2115. %
  2116. % forward.pass ==
  2117. %  BEGIN
  2118. %    if last.sort.label = sort.label then
  2119. %        last.extra.num := last.extra.num + 1
  2120. %        extra.label := int.to.chr$(last.extra.num)
  2121. %    else
  2122. %        last.extra.num := chr.to.int$("a")
  2123. %        extra.label := ""
  2124. %        last.sort.label := sort.label
  2125. %    fi
  2126. %  END
  2127. %
  2128. % reverse.pass ==
  2129. %  BEGIN
  2130. %    if next.extra = "b" then
  2131. %        extra.label := "a"
  2132. %    fi
  2133. %    label := label * extra.label
  2134. %    if width$(label) > longest.label.width then
  2135. %        longest.label := label
  2136. %        longest.label.width := width$(label)
  2137. %    fi
  2138. %    next.extra := extra.label
  2139. %  END
  2140. # endif 0
  2141.  
  2142. #if LAB_ALPH
  2143.  
  2144. #if SORTED
  2145.  
  2146. STRINGS { longest.label last.sort.label next.extra }
  2147.  
  2148. INTEGERS { longest.label.width last.extra.num }
  2149.  
  2150. FUNCTION {initialize.longest.label}
  2151. { 'longest.label "" :=
  2152.   'last.sort.label "" :=
  2153.   'next.extra "" :=
  2154.   'longest.label.width #0 :=
  2155.   'last.extra.num #0 :=
  2156. }
  2157.  
  2158. FUNCTION {forward.pass}
  2159. { last.sort.label sort.label =
  2160.     { 'last.extra.num last.extra.num #1 + :=
  2161.       'extra.label last.extra.num int.to.chr$ :=
  2162.     }
  2163.     { 'last.extra.num "a" chr.to.int$ :=
  2164.       'extra.label "" :=
  2165.       'last.sort.label sort.label :=
  2166.     }
  2167.   if$
  2168. }
  2169.  
  2170. FUNCTION {reverse.pass}
  2171. { next.extra "b" =
  2172.     { 'extra.label "a" := }
  2173.     'skip$
  2174.   if$
  2175.   'label label extra.label * :=
  2176.   label width$ longest.label.width >
  2177.     { 'longest.label label :=
  2178.       'longest.label.width label width$ :=
  2179.     }
  2180.     'skip$
  2181.   if$
  2182.   'next.extra extra.label :=
  2183. }
  2184.  
  2185. EXECUTE {initialize.longest.label}
  2186.  
  2187. ITERATE {forward.pass}
  2188.  
  2189. REVERSE {reverse.pass}
  2190.  
  2191. #else !SORTED
  2192.  
  2193. # if 0
  2194. % It still doesn't seem like a good idea to use an order-of-citation
  2195. % reference list when using alphabetic labels, but when this happens we
  2196. % must compute the longest label
  2197. # endif 0
  2198.  
  2199. STRINGS {longest.label}
  2200.  
  2201. INTEGERS {longest.label.width}
  2202.  
  2203. FUNCTION {initialize.longest.label}
  2204. { 'longest.label "" :=
  2205.   'longest.label.width #0 :=
  2206. }
  2207.  
  2208. FUNCTION {longest.label.pass}
  2209. { label width$ longest.label.width >
  2210.     { 'longest.label label :=
  2211.       'longest.label.width label width$ :=
  2212.     }
  2213.     'skip$
  2214.   if$
  2215. }
  2216.  
  2217. EXECUTE {initialize.longest.label}
  2218.  
  2219. ITERATE {longest.label.pass}
  2220.  
  2221. #endif SORTED
  2222.  
  2223. #else !LAB_ALPH
  2224.  
  2225. # if 0
  2226. % Now comes the computation for numeric labels.
  2227. % We use either the sorted order or original order.
  2228. % We still have to keep track of the longest (in width$ terms) label, for use
  2229. % by the "thebibliography" environment.
  2230. # endif 0
  2231.  
  2232. STRINGS {longest.label}
  2233.  
  2234. INTEGERS { number.label longest.label.width }
  2235.  
  2236. FUNCTION {initialize.longest.label}
  2237. { 'longest.label "" :=
  2238.   'number.label #1  :=
  2239.   'longest.label.width #0 :=
  2240. }
  2241.  
  2242. FUNCTION {longest.label.pass}
  2243. { 'label number.label int.to.str$ :=
  2244.   'number.label number.label #1 + :=
  2245.   label width$ longest.label.width >
  2246.     { 'longest.label label :=
  2247.       'longest.label.width label width$ :=
  2248.     }
  2249.     'skip$
  2250.   if$
  2251. }
  2252.  
  2253. EXECUTE {initialize.longest.label}
  2254.  
  2255. ITERATE {longest.label.pass}
  2256.  
  2257. #endif LAB_ALPH
  2258.  
  2259. # if 0
  2260. % Now we're ready to start writing the .BBL file.
  2261. % First we write the `preamble' containing the command
  2262. %     \begin{thebibliography}{...}
  2263. % where the `...' is the longest label.
  2264. %
  2265. % Then we call init.state.consts, for use by the output routines.
  2266. # endif 0
  2267.  
  2268. FUNCTION {preamble}
  2269. { "\begin{thebibliography}{"  longest.label  * "}" * write$
  2270.   newline$
  2271. }
  2272.  
  2273. EXECUTE {preamble}
  2274.  
  2275. EXECUTE {init.state.consts}
  2276.  
  2277. # if 0
  2278. % Now we produce the output for all the entries
  2279. # endif 0
  2280.  
  2281. ITERATE {call.type$}
  2282.  
  2283. # if 0
  2284. % Finally, we finish up by writing the `\end{thebibliography}' command.
  2285. # endif 0
  2286.  
  2287. FUNCTION {finish.up} { newline$ "\end{thebibliography}" write$ newline$ }
  2288.  
  2289. EXECUTE {finish.up}
  2290.